# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=python-terminaltables
_pkgname=${pkgname#python-}3
pkgver=3.1.10
pkgrel=1
pkgdesc='Generate simple tables in terminals from a nested list of strings.'
arch=('any')
url='https://github.com/matthewdeanmartin/terminaltables'
license=('MIT')
depends=('python')
makedepends=('python-setuptools' 'python-build' 'python-installer'
             'python-wheel' 'python-poetry' 'python-pbs-installer'
             'python-zstandard' 'python-httpx')
source=("https://github.com/matthewdeanmartin/$_pkgname/archive/refs/tags/v$pkgver.tar.gz"
        'python-3.8.patch')
sha512sums=('e68aaebbc65c46e636c980d3d187f965008d0b2badbd4dfad0da9c3eef06883c9b01853b8a0adc43f1c71863bcf249f1327d4334451bafcaf241a1effaa3144f'
            '9a33ef51cbd2854bf9acc247e2d966332229446158e7dae9cad25e03335eb9689d50b0a22234285aa56c707e6e93c12f950299efcfbe7e42ed527216090592f2')

prepare() {
  cd "$_pkgname-$pkgver"

  patch -Np1 < ../python-3.8.patch
}

build() {
  cd "$_pkgname-$pkgver"

  python -m build --no-isolation --wheel
}

package() {
  cd "$_pkgname-$pkgver"

  python -m installer --destdir="$pkgdir" --prefix=/usr dist/*.whl

  install -Dm 644 README.md -t "$pkgdir/usr/share/doc/$pkgname/"
  install -Dm 644 example*.py -t "$pkgdir/usr/share/doc/$pkgname/examples"
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

